/// @tags: SAM
#include <cstdio>
#include <cstring>
#include <iostream>

using namespace std;

namespace BlueQuantum {

int const N = 5e5 + 5;

int n, tot = 1, lst = 1, t, k;
int val[N << 1], sum[N << 1], buk[N], topo[N << 1];
char s[N];

struct Node {
  int ch[26], link, len;
} sam[N << 1];

inline void insert(int c) {
  int cur = ++tot, pos = lst;
  lst = cur, sam[cur].len = sam[pos].len + 1, val[cur] = 1;
  while (pos && !sam[pos].ch[c]) sam[pos].ch[c] = cur, pos = sam[pos].link;
  if (pos == 0) return sam[cur].link = 1, void();
  int q = sam[pos].ch[c];
  if (sam[q].len == sam[pos].len + 1) return sam[cur].link = q, void();
  int clone = ++tot;
  sam[clone] = sam[q];
  sam[clone].len = sam[pos].len + 1;
  sam[q].link = sam[cur].link = clone;
  while (pos && sam[pos].ch[c] == q) sam[pos].ch[c] = clone, pos = sam[pos].link;
}

void solve(int u) {
  if (k <= val[u]) return;
  k -= val[u];
  for (int i = 0; i < 26; ++i)
    if (sam[u].ch[i]) {
      if (k > sum[sam[u].ch[i]]) {
        k -= sum[sam[u].ch[i]];
        continue;
      }
      return cout << char('a' + i), solve(sam[u].ch[i]);
    }
}

inline int main() {
  cin >> s >> t >> k;
  n = strlen(s);
  for (int i = 0; i < n; ++i) insert(s[i] - 'a');
  for (int i = 1; i <= tot; ++i) buk[sam[i].len]++;
  for (int i = 1; i <= n; ++i) buk[i] += buk[i - 1];
  for (int i = 1; i <= tot; ++i) topo[buk[sam[i].len]--] = i;
  for (int i = tot; i; --i)
    t ? (val[sam[topo[i]].link] += val[topo[i]]) : (val[topo[i]] = 1);
  val[1] = 0;
  for (int i = tot; i; --i) {
    sum[topo[i]] = val[topo[i]];
    for (int j = 0; j < 26; ++j) sum[topo[i]] += sum[sam[topo[i]].ch[j]];
  }
  k > sum[1] ? cout << "-1", void() : solve(1);
  return 0;
}

}  // namespace BlueQuantum

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("P3975 [TJOI2015] 弦论.in", "r", stdin);
  freopen("P3975 [TJOI2015] 弦论.out", "w", stdout);
#endif
#endif

  ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  return BlueQuantum::main();
}
